<template>
  <div class="identity-quick-switch" v-if="showQuickSwitch">
    <div class="switch-container">
      <div class="switch-header">
        <h3>切换身份视角</h3>
        <p>选择不同身份查看相关内容</p>
      </div>
      
      <div class="switch-buttons">
        <button 
          v-for="identity in availableIdentities" 
          :key="identity.value"
          @click="switchIdentity(identity.value)"
          :class="['switch-btn', { active: identity.value === currentIdentity }]"
        >
          <i :class="identity.icon"></i>
          <span>{{ identity.label }}</span>
        </button>
      </div>
      
      <button class="close-btn" @click="hideQuickSwitch">
        <i class="fas fa-times"></i>
      </button>
    </div>
  </div>
</template>

<script>
export default {
  name: 'IdentityQuickSwitch',
  props: {
    currentIdentity: {
      type: String,
      default: null
    },
    show: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      availableIdentities: [
        { value: 'investor', label: '投资者', icon: 'fas fa-chart-line' },
        { value: 'enterprise', label: '企业方', icon: 'fas fa-building' },
        { value: 'student', label: '大学生', icon: 'fas fa-graduation-cap' }
      ],
      showQuickSwitch: this.show
    }
  },
  watch: {
    show(newVal) {
      this.showQuickSwitch = newVal
    }
  },
  methods: {
    switchIdentity(identity) {
      this.$emit('identity-changed', identity)
      this.hideQuickSwitch()
    },
    hideQuickSwitch() {
      this.showQuickSwitch = false
      this.$emit('close')
    }
  }
}
</script>

<style scoped>
.identity-quick-switch {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.95) 0%, rgba(30, 41, 59, 0.95) 100%);
  backdrop-filter: blur(20px);
  z-index: 9999;
  padding: 1rem 0;
  border-bottom: 1px solid rgba(59, 130, 246, 0.3);
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from {
    transform: translateY(-100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.switch-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 2rem;
  position: relative;
}

.switch-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.switch-header h3 {
  color: white;
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
}

.switch-header p {
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.9rem;
}

.switch-buttons {
  display: flex;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.switch-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.8rem 1.5rem;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 25px;
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
}

.switch-btn:hover {
  background: rgba(59, 130, 246, 0.2);
  border-color: rgba(59, 130, 246, 0.4);
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
}

.switch-btn.active {
  background: linear-gradient(135deg, #3b82f6, #06b6d4);
  border-color: rgba(59, 130, 246, 0.6);
  color: white;
  box-shadow: 0 4px 20px rgba(59, 130, 246, 0.4);
}

.switch-btn i {
  font-size: 1rem;
}

.close-btn {
  position: absolute;
  top: 0;
  right: 0;
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.close-btn:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.4);
  color: #ef4444;
  transform: scale(1.1);
}

.close-btn i {
  font-size: 0.9rem;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .switch-container {
    padding: 0 1rem;
  }
  
  .switch-buttons {
    gap: 0.5rem;
  }
  
  .switch-btn {
    padding: 0.6rem 1rem;
    font-size: 0.8rem;
  }
  
  .close-btn {
    width: 35px;
    height: 35px;
  }
}

@media (max-width: 480px) {
  .switch-buttons {
    flex-direction: column;
    align-items: center;
  }
  
  .switch-btn {
    width: 100%;
    max-width: 200px;
    justify-content: center;
  }
}
</style>
